package com.cbb.lease.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cbb.lease.pojo.entity.TbCar;
import com.cbb.lease.mapper.TbCarMapper;
import com.cbb.lease.pojo.vo.AllCatVo;
import com.cbb.lease.pojo.vo.Catvo;
import com.cbb.lease.service.TbCarService;
import com.cbb.lease.util.uuIDBytime;
import com.gsj.common.pojo.R;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TbCar)表服务实现类
 *
 * @author makejava
 * @since 2021-07-23 15:23:12
 */
@Service("tbCarService")
public class TbCarServiceImpl implements TbCarService {
    @Resource
    private TbCarMapper tbCarDao;

    @Override
    public R getAllCat(Integer currentPage, Integer pageSize, Catvo catvo) {
        Page<AllCatVo> page = new Page<>(currentPage,pageSize);
        IPage<AllCatVo> allCat = tbCarDao.getAllCat(page,catvo);
        return R.ok().put("records",allCat.getRecords()).put("total",allCat.getTotal());
    }

    @Override
    public R updateCar(TbCar car) {
        int update = tbCarDao.updateById(car);
        return R.ok();
    }

    @Override
    public R addCar(TbCar car) {
        uuIDBytime idByTime = new uuIDBytime();
        String s = idByTime.getUUID();
        car.setVin(s);
        int insert = tbCarDao.insert(car);
        return R.ok();
    }

    @Override
    public R deleteById(Integer id) {
        int i = tbCarDao.deleteById(id);
        return R.ok();
    }

    @Override
    public R updateCarState(Integer id) {
        int i = tbCarDao.updateCarState(id);
        return R.ok();
    }

    @Override
    public R updateCarState1(Integer id) {
        int i = tbCarDao.updateCarState1(id);
        return R.ok();
    }


}
